package com.ewhale.feitengguest.ui.user.task.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ewhale.feitengguest.R;
import com.ewhale.feitengguest.dto.TaskListDto;
import com.simga.library.adapter.recyclerview.BaseViewHolder;
import com.simga.library.adapter.recyclerview.MutiRecyclerAdapter;
import com.simga.library.utils.StringUtil;
import com.simga.library.utils.glide.GlideUtil;

import java.util.List;

import butterknife.BindView;

public class TaskListAdpater extends MutiRecyclerAdapter<TaskListDto> {

    public TaskListAdpater(List<TaskListDto> data) {
        super(data, R.layout.item_task);
    }

    @Override
    protected BaseViewHolder<TaskListDto> getViewHolder() {
        return new ViewHolder(view);
    }

    class ViewHolder extends BaseViewHolder<TaskListDto> {
        @BindView(R.id.iv_cover)
        ImageView mIvCover;
        @BindView(R.id.tv_title)
        TextView mTvTitle;
        @BindView(R.id.tv_times)
        TextView mTvTimes;
        @BindView(R.id.tv_price)
        TextView mTvPrice;
        @BindView(R.id.tv_yizhuan)
        TextView mTvYizhuan;

        public ViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void build(TaskListDto object, int position) {
            GlideUtil.loadPicture(object.getImg(), mIvCover);
            mTvTitle.setText(object.getTitle());
            mTvTimes.setText("剩余" + object.getSurplusNum() + "次");
            mTvYizhuan.setText(object.getFinishNum() + "人已赚");
            mTvPrice.setText("¥" + StringUtil.to2Decimal(StringUtil.to2Double(object.getUnitPrice())));
        }
    }
}
